<?php

namespace App\Http\Controllers;

use App\Models\User;
use App\Models\UserAddress;
use Illuminate\Http\Request;

class UserController extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index(Request $request): \Illuminate\Http\JsonResponse
    {
        $params = $request->all();

        $data = User::where('id', $params['id'])->get()->toArray();
        $data = current($data);

        $data['address'] = (new UserAddress())->getList(['user_id' => $params['id'], 'status' => 'NORMAL']);

        return response()->json(['status' => 1, 'data' => $data]);
    }
}
